<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
      {include file="public/header" /}
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>分类名称
              </label>
              <input type="hidden" id="CateId" value="{$Ret.id}">
              <div class="layui-input-inline">
                  <input type="text" id="name" name="name" required="" lay-verify="required"
                  autocomplete="off" value="{$Ret.name}" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>避免输入非法字符
              </div>
          </div>
          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button type="button" class="layui-btn" onclick="updateCate()">
                  修改
              </button>
          </div>
      </form>
    </div>
    <script>
        function updateCate() {
            var name = $('#name').val();
            var id = $('#CateId').val();
            var isTj = 1;
            if(name==undefined || name=="" || name==null || id==undefined || id=="" || id==null){
                isTj = 2;
                layer.alert('请输入分类名称', {
                    skin: 'layui-layer-molv' //样式类名
                    ,closeBtn: 0,icon: 5
                });
            }
            if(isTj == 1){
                $.ajax({
                    url:"{:url('group/updateGroup')}",
                    type:'post',
                    dataType:"json",
                    data:{
                        name:name,
                        id:id
                    },
                    success:function(data){
                        data = JSON.parse(data);
                        if(data.status == 1){
                            layer.alert("修改成功", {closeBtn: 0,icon: 6},function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload();
                            });
                        }else{
                            layer.alert(data.msg, {
                                skin: 'layui-layer-molv' //样式类名
                                ,closeBtn: 0,icon: 5
                            });
                        }
                    }
                })
            }
        }
    </script>
  </body>

</html>